package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CaseComplaintMeans;
import com.ktgj.customer.service.ICaseComplaintMeansService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 投诉工单_投诉方式Controller
 * 
 * @author ruoyi
 * @date 2022-05-27
 */
@RestController
@RequestMapping("/means")
public class CaseComplaintMeansController extends BaseController
{
    @Autowired
    private ICaseComplaintMeansService caseComplaintMeansService;

    /**
     * 查询投诉工单_投诉方式列表
     */
    @PreAuthorize(hasPermi = "system:means:list")
    @GetMapping("/list")
    public TableDataInfo list(CaseComplaintMeans caseComplaintMeans)
    {
        startPage();
        List<CaseComplaintMeans> list = caseComplaintMeansService.selectCaseComplaintMeansList(caseComplaintMeans);
        return getDataTable(list);
    }

    @PostMapping("/selectMeansList")
    public AjaxResult selectMeansList(){
        List<CaseComplaintMeans> list=caseComplaintMeansService.selectMeansList();
        if (list.size()>0) {
            return AjaxResult.success(list);
        }else {
            return AjaxResult.success("相关数据为空");
        }
    }

    /**
     * 导出投诉工单_投诉方式列表
     */
    @PreAuthorize(hasPermi = "system:means:export")
    @Log(title = "投诉工单_投诉方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CaseComplaintMeans caseComplaintMeans) throws IOException
    {
        List<CaseComplaintMeans> list = caseComplaintMeansService.selectCaseComplaintMeansList(caseComplaintMeans);
        ExcelUtil<CaseComplaintMeans> util = new ExcelUtil<CaseComplaintMeans>(CaseComplaintMeans.class);
        util.exportExcel(response, list, "投诉工单_投诉方式数据");
    }

    /**
     * 获取投诉工单_投诉方式详细信息
     */
    @PreAuthorize(hasPermi = "system:means:query")
    @GetMapping(value = "/{complaintMeansId}")
    public AjaxResult getInfo(@PathVariable("complaintMeansId") Long complaintMeansId)
    {
        return AjaxResult.success(caseComplaintMeansService.selectCaseComplaintMeansById(complaintMeansId));
    }

    /**
     * 新增投诉工单_投诉方式
     */
    @PreAuthorize(hasPermi = "system:means:add")
    @Log(title = "投诉工单_投诉方式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CaseComplaintMeans caseComplaintMeans)
    {
        return toAjax(caseComplaintMeansService.insertCaseComplaintMeans(caseComplaintMeans));
    }

    /**
     * 修改投诉工单_投诉方式
     */
    @PreAuthorize(hasPermi = "system:means:edit")
    @Log(title = "投诉工单_投诉方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CaseComplaintMeans caseComplaintMeans)
    {
        return toAjax(caseComplaintMeansService.updateCaseComplaintMeans(caseComplaintMeans));
    }

    /**
     * 删除投诉工单_投诉方式
     */
    @PreAuthorize(hasPermi = "system:means:remove")
    @Log(title = "投诉工单_投诉方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{complaintMeansIds}")
    public AjaxResult remove(@PathVariable Long[] complaintMeansIds)
    {
        return toAjax(caseComplaintMeansService.deleteCaseComplaintMeansByIds(complaintMeansIds));
    }
}
